package com.ruoyi.web.controller.statistics;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistics.domain.ResInformationPraise;
import com.ruoyi.statistics.service.IResInformationPraiseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资讯点赞Controller
 * 
 * @author ruoyi
 * @date 2021-12-20
 */
@RestController
@RequestMapping("/statistics/praise")
public class ResInformationPraiseController extends BaseController
{
    @Autowired
    private IResInformationPraiseService resInformationPraiseService;

    /**
     * 查询资讯点赞列表
     */
    @PreAuthorize("@ss.hasPermi('statistics:praise:list')")
    @GetMapping("/list")
    public TableDataInfo list(ResInformationPraise resInformationPraise)
    {
        startPage();
        List<ResInformationPraise> list = resInformationPraiseService.selectResInformationPraiseList(resInformationPraise);
        return getDataTable(list);
    }

    /**
     * 导出资讯点赞列表
     */
    @PreAuthorize("@ss.hasPermi('statistics:praise:export')")
    @Log(title = "资讯点赞", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResInformationPraise resInformationPraise)
    {
        List<ResInformationPraise> list = resInformationPraiseService.selectResInformationPraiseList(resInformationPraise);
        ExcelUtil<ResInformationPraise> util = new ExcelUtil<ResInformationPraise>(ResInformationPraise.class);
        util.exportExcel(response, list, "资讯点赞数据");
    }

    /**
     * 获取资讯点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistics:praise:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(resInformationPraiseService.selectResInformationPraiseById(id));
    }

    /**
     * 新增资讯点赞
     */
    @PreAuthorize("@ss.hasPermi('statistics:praise:add')")
    @Log(title = "资讯点赞", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResInformationPraise resInformationPraise)
    {
        return toAjax(resInformationPraiseService.insertResInformationPraise(resInformationPraise));
    }

    /**
     * 修改资讯点赞
     */
    @PreAuthorize("@ss.hasPermi('statistics:praise:edit')")
    @Log(title = "资讯点赞", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResInformationPraise resInformationPraise)
    {
        return toAjax(resInformationPraiseService.updateResInformationPraise(resInformationPraise));
    }

    /**
     * 删除资讯点赞
     */
    @PreAuthorize("@ss.hasPermi('statistics:praise:remove')")
    @Log(title = "资讯点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(resInformationPraiseService.deleteResInformationPraiseByIds(ids));
    }
}
